package com.mcg.jituan;

import java.net.MalformedURLException;
import java.rmi.AlreadyBoundException;
import java.rmi.Naming;
import java.rmi.RemoteException;
import java.rmi.registry.LocateRegistry;

/**
 * 创建RemoteMath类的实例并在rmiregistry中注册。
 */
public class RMIAshOMC {
    public static void main(String[] args)  {
        try {
            IAshOmc ashOMC = new AshOmc();
            // 注册远程对象,向客户端提供远程对象服务。默认端口是1099
            LocateRegistry.createRegistry(1098);
            Naming.bind("rmi://172.17.2.124:1098/ashOmc", ashOMC);
            System.out.println("-------jituan omc start...");
        } catch (RemoteException e) {
            System.out.println("创建远程对象发生异常！");
            e.printStackTrace();
        } catch (AlreadyBoundException e) {
            System.out.println("发生重复绑定对象异常！");
            e.printStackTrace();
        } catch (MalformedURLException e) {
            System.out.println("发生URL畸形异常！");
            e.printStackTrace();
        }


    }
}
